using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace DividerPanel
{
    public partial class Divider : UserControl
    {
        public Divider()
        {
            InitializeComponent();
        }

        /// <summary>
        /// The text to display
        /// </summary>
        [Bindable(true), Category("Misc"), DefaultValue("Displayed text"),
		Description("")]
        public string DisplayText
        {
            get { return this.lblDisplay.Text; }
            set
            {
                if (this.lblDisplay.Text != value)
                {
                    this.lblDisplay.Text = value;
                    this.Invalidate();
                    
                }
            }
        }

        /// <summary>
        /// The color of text
        /// </summary>
        [Bindable(true), Category("Misc"), DefaultValue("Text color")]
        public Color TextColour
        {
            get { return this.lblDisplay.ForeColor; }
            set
            {
                if (this.lblDisplay.ForeColor != value)
                {
                    this.lblDisplay.ForeColor = value;
                    this.Invalidate();
                }
            }
        }

        /// <summary>
        /// The side of text (left -right)
        /// </summary>
        [Bindable(true), Category("Misc"), DefaultValue("Text side")]
        public DockStyle TextSide
        {
            get { return this.lblDisplay.Dock; }
            set
            {
                if (this.lblDisplay.Dock != value)
                {
                    this.lblDisplay.Dock = value;
                    this.Invalidate();
                }
            }
        }

        /// <summary>
        /// The font of text
        /// </summary>
        [Bindable(true), Category("Misc"), DefaultValue("font")]
        public Font TextFont
        {
            get { return this.lblDisplay.Font; }
            set
            {
                if (this.lblDisplay.Font != value)
                {
                    this.lblDisplay.Font = value;
                    this.Invalidate();
                }
            }
        }

        /// <summary>
        /// The Border3DStyle
        /// </summary>
        [Bindable(true), Category("Misc"), DefaultValue("Border3DStyle.SunkenOuter")]
        protected Border3DStyle _Border3DStyle = Border3DStyle.SunkenOuter;
        public Border3DStyle Border3DStyle {
            get { return _Border3DStyle; }
            set
            {
                if (_Border3DStyle != value)
                {
                    _Border3DStyle = value;
                    this.Invalidate();
                }
            }
        }

        private void pnDivider_Paint(object sender, PaintEventArgs e)
        {
            if (pnDivider.Width == 0 || pnDivider.Height == 0) return;

            //base.OnPaint(e);

            System.Windows.Forms.ControlPaint.DrawBorder3D(
                e.Graphics,
                pnDivider.ClientRectangle,
                _Border3DStyle,
                Border3DSide.Top);
        }

        private void Divider_Load(object sender, EventArgs e)
        {
            if (DesignMode) return;
        }
    }
}
